<!--
 * @Descripttion: 
 * @Author: yuxi
 * @Date: 2022-09-15 14:58:04
 * @LastEditors: yuxi
 * @LastEditTime: 2023-08-28 20:12:17
-->
<template>
  <div class="map-container">
    <MiningMap :center="center" :zoom="zoom">
      <MiningTiandituLayer :ak="key" @ready="ready"></MiningTiandituLayer>
      <MiningVectorLayer :featureStyle="style">
        <MiningPoint
          v-for="(feature, fi) in features"
          :key="fi"
          :feature="feature"
        ></MiningPoint>
      </MiningVectorLayer>
    </MiningMap>
  </div>
</template>

<script>
import MiningMap from 'mining-map/Map'
import MiningTiandituLayer from 'mining-map/Layers/TiandituLayer'
import MiningVectorLayer from 'mining-map/Layers/VectorLayer'
import MiningPoint from 'mining-map/Features/Point';
import { TiandituKey,CityCoordinates } from '@/config/config.js';

import Feature from 'ol/Feature';
import Point from 'ol/geom/Point';
import {  Icon, Circle as CircleStyle, Fill, Stroke } from 'ol/style';
import { MiningStyle } from 'mining-map/Style';
import marker from '@/assets/images/marker.png'

export default {
  name: 'FeaturePoint',
  title: 'Point',
  parentTitle: 'Feature',
  components: {
    MiningMap,
    MiningTiandituLayer,
    MiningVectorLayer,
    MiningPoint
  },
  data () {
    const features = [ CityCoordinates.BeiJing,  CityCoordinates.ShangHai,  CityCoordinates.XiAn].map(coords => new Feature({
      type: 'Point',
      geometry: new Point(coords),
      name: 'City',
    })); 
    let styleStr = {"image":{"radius":10,"scale":1,"rotation":0,"rotateWithView":false,"fill":{"color":"#ff00ff"},"stroke":{"color":"#fff","lineDash":null,"width":5}}}

    const style = new MiningStyle()
    style.fromJSON(styleStr)
    return {
      features,
      style,
      center: [117.730311, 35.698681],
      zoom: 5,
      key: TiandituKey,
    }
  },
  methods: {
    ready (arg) {
      console.log(arg)
    }
  }

}
</script>

<style>
body,
html {
  padding: 0;
  margin: 0;
}

.map-container {
  width: 100%;
  height: 100vh;
}
</style>